package com.example.mobile2021606129ly0330;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity_temp extends AppCompatActivity {

    private Button butTemRes;
    private EditText edIntTem;
    private TextView textTemRes;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_temp);
        initView();
        butTemRes.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int a = Integer.parseInt(edIntTem.getText().toString());
                int c = a - 32;
                double d = c / 1.8;
                int e = (int) Math.pow(d, 2);
                textTemRes.setText(e);


            }
        });

    }

    private void initView() {

        butTemRes = (Button) findViewById(R.id.but_tem_res);
        edIntTem = (EditText) findViewById(R.id.ed_int_tem);
        textTemRes = (TextView) findViewById(R.id.text_tem_res);

    }
}